package com.cybersapien.comng.engine.context;

import java.util.Iterator;

import com.cybersapien.comng.engine.entity.IEntity;
import com.cybersapien.comng.engine.event.engine.IEventEngine;
import com.cybersapien.comng.engine.event.gui.IEventGUI;
import com.cybersapien.comng.engine.type.IStack;
import com.cybersapien.comng.engine.type.RawStack;

class Context implements IContext {

	IStack<IEventEngine> engineEvents;
	IStack<IEventGUI> guiEvents;
	Iterator<IEventEngine> eventEngineIterator;
	IEventEngine currentEventEngine;

	Context() {
		engineEvents = new RawStack<IEventEngine>();
		guiEvents = new RawStack<IEventGUI>();
		eventEngineIterator = engineEvents.iterator();
		currentEventEngine = null;
	}

	@Override
	public void addEventEngine(IEventEngine event) {
		engineEvents.push(event);
	}

	@Override
	public void addEventGUI(IEventGUI event) {
		guiEvents.push(event);
	}

	@Override
	public boolean hasNextEventEngine() {
		return eventEngineIterator.hasNext();
	}

	@Override
	public IEventEngine currentEventEngine() {
		return currentEventEngine;
	}

	@Override
	public IEventEngine nextEventEngine() {
		currentEventEngine = eventEngineIterator.next();
		return currentEventEngine;
	}

	@Override
	public <ENTITY extends IEntity> ENTITY findEntity(String id, Class<ENTITY> type) {
		return null;
	}

	@Override
	public void release() {

	}

}
